<!DOCTYPE html>
<html>
	<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<title>jQuery Mobile Docs - Sample Form Submit</title>
	<link rel="stylesheet"  href="../../css/themes/default/jquery.mobile.css" />
	<link rel="stylesheet" href="../_assets/css/jqm-docs.css"/>

	<script src="../../js/jquery.js"></script>
	<script src="../../docs/_assets/js/jqm-docs.js"></script>
	<script src="../../js/jquery.mobile.js"></script>

</head>
<body>

	<div data-role="page" class="type-interior">

		<div data-role="header" data-theme="f">
		<h1>Forms</h1>
		<a href="../../" data-icon="home" data-iconpos="notext" data-direction="reverse">Home</a>
		<a href="../nav.html" data-icon="search" data-iconpos="notext" data-rel="dialog" data-transition="fade">Search</a>
	</div><!-- /header -->

	<div data-role="content">
			<div class="content-primary">

			<h2>Ajax form submission</h2>

			<p>In jQuery Mobile, form submissions are automatically handled using Ajax whenever possible, creating a smooth transition between the form and the result page. To ensure your form submits as intended, be sure to specify <code>action</code> and <code>method</code> properties on your form element. When unspecified, the method will default to <code>get</code>, and the <code>action</code> will default to the current page's relative path (found via <code>$.mobile.path.get()</code>)</p>
			<p>Forms also accept attributes for transitions just like anchors, such as <code>data-transition="pop"</code> and <code>data-direction="reverse"</code>. To submit a form without Ajax, you can either disable Ajax form handling globally, or per form via the <code>data-ajax="false"</code> attribute. The <code>target</code> attribute (as in <code>target="_blank"</code>) is respected on forms as well, and will default to the browser's handling of that target when the form submits. Note that unlike anchors, the <code>rel</code> attribute is not allowed on forms.</p>


            <h2>Default Ajax form example</h2>
            <p>This demonstrates automated ajax handling of form submissions. The form below is configured to send a <code>GET</code> request to <code>forms-sample-response.php</code>. On submit, jQuery Mobile will make sure that the Url specified is able to be retrieved via Ajax, and handle it appropriately. Keep in mind that just like ordinary HTTP form submissions, jQuery Mobile allows <code>GET</code> result pages to be bookmarked by updating the URL hash when the response returns successfully. Also like ordinary form submissions, <code>POST</code> requests do not contain query parameters in the hash, so they are not bookmarkable.</p>
			<form action="forms-sample-response.php" method="get" class="ui-body ui-body-a ui-corner-all">
				<fieldset>
					<div data-role="fieldcontain">
						<label for="shipping" class="select">Shipping method:</label>
						<select name="shipping" id="shipping">
							<option value="Standard shipping">Standard: 7 day</option>
							<option value="Rush shipping">Rush: 3 days</option>
							<option value="Express shipping">Express: next day</option>
							<option value="Overnight shipping">Overnight</option>
						</select>
					</div>
					<button type="submit" data-theme="b" name="submit" value="submit-value">Submit</button>
				</fieldset>
			</form>

			<h2>Non-Ajax form example</h2>

			 <p>To prevent form submissions from being automatically handled with Ajax, add the <code>data-ajax="false"</code> attribute to the form element. You can also turn off Ajax form handling completely via the <code>ajaxEnabled</code> <a href="../api/globalconfig.html">global config option</a>.</p>

            <p>The form below is identical to the one above except for the addition of the <code>data-ajax="false"</code> attribute. When the submit button is pressed, it will result in a full page refresh.</p>
			<form action="forms-sample-response.php" method="get" data-ajax="false" class="ui-body ui-body-a ui-corner-all">
				<fieldset>
					<div data-role="fieldcontain">
						<label for="shipping" class="select">Shipping method:</label>
						<select name="shipping" id="shipping">
							<option value="Standard shipping">Standard: 7 day</option>
							<option value="Rush shipping">Rush: 3 days</option>
							<option value="Express shipping">Express: next day</option>
							<option value="Overnight shipping">Overnight</option>
						</select>
					</div>
					<button type="submit" data-theme="b" name="submit" value="submit-value">Submit</button>
				</fieldset>
			</form>

			<h2>Self-submitting Forms</h2>
			<p>You can submit forms to the same URL you're currently viewing by setting the form's <code>action</code> attribute to that URL. <A href="forms-sample-selfsubmit.php">This page demonstrates.</a></p>
			<p>When a <code>POST</code> request is submitted to a page that's already in the DOM (which would commonly happen when submitting a form to the same URL currently in view), the response URL will be identical to that existing page, as <code>POST</code> requests do not append query string parameters to the URL. In this situation, jQuery Mobile will replace the page that submitted the form with the page returned in the response body.</p>

			</div><!--/content-primary -->

			<div class="content-secondary">

				<div data-role="collapsible" data-collapsed="true" data-theme="b" data-content-theme="d">

						<h3>More in this section</h3>

						<ul data-role="listview" data-theme="c" data-dividertheme="d">

							<li data-role="list-divider">Form elements</li>
							<li><a href="docs-forms.html">Form basics</a></li>
							<li><a href="forms-all.html">Form element gallery</a></li>
							<li><a href="forms-all-mini.html">Mini form element gallery</a></li>
              <li><a href="textinputs/">Text inputs</a></li>
							<li><a href="search/">Search inputs</a></li>
							<li><a href="slider/">Slider</a></li>
							<li><a href="switch/">Flip toggle switch</a></li>
							<li><a href="radiobuttons/">Radio buttons</a></li>
							<li><a href="checkboxes/">Checkboxes</a></li>
							<li><a href="selects/">Select menus</a></li>
							<li><a href="forms-themes.html">Theming forms</a></li>
							<li><a href="forms-all-native.html">Native form elements</a></li>
							<li data-theme="a"><a href="forms-sample.html">Submitting forms</a></li>


						</ul>
				</div>
			</div>

		</div><!-- /content -->

		<div data-role="footer" class="footer-docs" data-theme="c">
				<p>&copy; 2011-12 The jQuery Foundation</p>
		</div>

		</div><!-- /page -->

		</body>
		</html>
